/*
 * Write a program that reads a number n and a
 * sequence of n numbers and finds in the
 * sequence the longest area of adjacent equal
 * elements.
 */

package _3;

import java.util.Scanner;

public class _12 {
	public static void main (String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = 0;

		if (scn.hasNextInt())
			n = scn.nextInt();
		else {
			System.out.println("error: mismatched input");
			System.exit(1);
		}

		int cur = 0, streak = 0, max = 0, last = 0;
		int[] seq = new int[n];

		for (int i = 0; i < n; i++) {
			System.out.printf("seq[%d] ?= ", i);
			if (scn.hasNextInt())
				seq[i] = scn.nextInt();
			else {
				System.err.println("error: mismatched input");
				System.exit(1);
			}

			if (i == 0) {
				cur = seq[i];
				streak = 1;
			} else {
				if (seq[i] == cur)
					streak++;
				else {
					if (max < streak) {

						max = streak;
						last = i;
					}

					cur = seq[i];
					streak = 1;
				}
			}
		}

		System.out.print("{");
		for (int i = last - max; i < last; i++)
			System.out.printf("%d ", seq[i]);
		System.out.print("}");
	}
}
